<?php include('./templete/public/head.php')?>
<body class="bgcolor mbHeight">
<!--金点子详情-->
<div class="golden-idea-detail zj-detail-main">
    <div class="ideal-detail1">
        <div class="detail-text">
            <p class="p1 pfbold"><?php echo $rows['title']?></p>
            <div class="p2">
                <?php echo nl2br($rows['content'])?>
                <div class="p2-img mui-content-padded">
                    <!--                    <img src="_images/head-img4.png" data-preview-src="" data-preview-group="1"/>-->
                    <?php if($rows['img_url']){?>
                    <img src="<?php echo $rows['img_url']?>" data-preview-src="" data-preview-group="1"/>
                    <?php }?>
                </div>
            </div>
            <div class="p3">
                <p class="p3-1">
                    <img src="<?php echo $rows['user_head']?>" class="head-img"/>
                    <span><?php echo $rows['author_name']?> <?php echo date('Y-m-d',strtotime($rows['add_time']))?></span>
                </p>
                <p class="p3-2">
                    <span onclick="topic_appreciate(1,<?php echo $rows['id']?>,this)" <?php if($appreciate){echo 'class="active"';}?>><i class="topic_appreciate_sum"><?php echo $rows['appreciate']?></i><i class="iconfont icon-dianzan"></i></span>
                    <span onclick="topic_appreciate(2,<?php echo $rows['id']?>,this)" <?php if($collect){echo 'class="active"';}?>><i class="">收藏</i><i class="iconfont icon-shoucang1"></i></span>
                    <?php if((session('user_info')['userid']==$rows['author'])&&($rows['status']==1)){?>
                        <span class="close_topic">关闭<i class="iconfont icon-iconfonticon2"></i></span>
                    <?php }?>
                </p>
            </div>

        </div>
    </div>
    <div class="ideal-detail2">
        <ul class="comm-table-view">
            <li class="table-view-cell">
                <a>
                    <span>地点</span>
                    <span><?php echo $rows['place']?></span>
                </a>
            </li>
            <?php if($rows['link']){?>
            <li class="table-view-cell">
                <a href="<?php echo $rows['link']?>">
                    <span>站外链接</span>
                    <span onclick="get_link('<?php echo $rows['link']?>')">去看看</span>
                </a>
            </li>
            <?php }?>
            <li class="table-view-cell">
                <a>
                    <?php if($rows['reward_integral']){?>
                        <span>悬赏积分</span>
                        <span><?php echo $rows['reward_integral']?></span>
                    <?php }?>

                </a>
            </li>
            <li class="table-view-cell">
                <a>
                    <?php if($rows['time']){?>
                        <span>出游时间</span>
                        <span><?php echo $rows['time']?></span>
                    <?php }?>


                    <?php if($rows['travel_cate']){?>
                        <span>分享分类</span>
                        <span><?php echo $rows['travel_cate']?></span>
                    <?php }?>
                </a>
            </li>
        </ul>
    </div>
    <!--评论-->
    <div class="comment-main">
        <ul class="comment-list">
            <?php if(($rows['status']==2)&&($rows['type']==2)){?>
                <script>
                    $.ajax({
                        url:"<?php echo url('comment/get_comment_list')?>",
                        data:{
                            topic_id:<?php echo $rows['id']?>,
                            first:1,
                        },
                        success:function (data) {
                            $(".comment-list").html(data);
                        }
                    })
                </script>
            <?php }?>
        </ul>
    </div>
    <!--底部评论固定-->
    <div class="comment-fixed">
        <p class="p2"><input type="text" id="comment" placeholder="点评一下吧"/></p>
        <p class="p3" id="publish_comment"><a href="#">提交</a></p>
    </div>
</div>
</body>

<script src="_js/plug/mui.zoom.js"></script>
<script src="_js/plug/mui.previewimage.js"></script>

<script>
    $('#publish_comment').click(function () {
        var comment = $('#comment').val();
        if(!comment){
            layer.msg('请输入评论内容');
            return false;
        }
        layer.msg('请稍等');
        var loading = layer.load(1, {shade: [0.4, '#000']}); //0代表加载的风格，支持0-2
        $.ajax({
            url:'<?php echo url('publish_comment')?>',
            type:'post',
            data:{
                content:comment,
                topic_id:<?php echo $rows['id']?>
            },
            success:function (data) {
                layer.msg(data.msg);
                if(data.code==1){
                   location.reload();
                }
                setTimeout(function () {
                    layer.closeAll();
                }, 1000);
            }
        })
    });
    //获取评论
    function get_comment() {
        $.ajax({
            url:'<?php echo url('comment/get_comment_list')?>',
            data:{
                topic_id:<?php echo $rows['id']?>,
                type:<?php echo $rows['type']?>
            },
            success:function (data) {
                $('.comment-list').append(data);
            }
        })
    };
    get_comment();

    //获取更多评论
    $(function() {
        var page = 2;
        var load_flag = true;
        $(window).scroll(function() {
            var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            var documentheight = parseFloat($(document).height());
            if (documentheight - totalheight <= 200) {
                $("#loadmore").show();
                if(load_flag){
                    load_flag=!load_flag;
                    $.ajax({
                        url: '<?php echo url('comment/get_comment_list')?>',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            page:page,
                            topic_id:<?php echo $rows['id']?>,
                            type:<?php echo $rows['type']?>
                        },
                        success: function(data) {
                            if (data) {
                                $('.comment-list').append(data);
                                load_flag=!load_flag;
                                page++;
                            }
                        }
                    })
                }
            }
        });
    });
    mui.previewImage();
    //关闭话题
    $('.close_topic').click(function () {
        $.ajax({
            url:'<?php echo url("close_topic")?>',
            data:{
                topic_id:<?php echo $rows['id']?>
            },
            success:function (data) {
                layer.msg(data.msg);
                setTimeout(function () {
                    location.reload();
                },1000)
            }
        })
    })

    function get_link(link) {
        window.location.href=link;
    }
</script>

</html>